<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
		<title>用户管理</title>
		[#include "/html/include/easyuicss.html" /]
		[#include "/html/include/easyuijs.html" /]
		<script type="text/javascript" src="${app }/static/js/common.utils.js"></script>
	</head>
	<body class="easyui-layout" data-options="fit:true" style="overflow-y: hidden;">
	<table id="users" class="easyui-datagrid"
		   data-options="
				url: '${app}/sysmgr/user/list.do',
				method: 'post',
				queryParams: {userName: $('#userName').val(), userMobile: $('#userMobile').val()},
				fitColumns: true,
				singleSelect: true,
				striped: true,
				toolbar: '#tb',
				onLoadSuccess: onLoadSuccess,
				pagination: true,
				pageSize: 20,
				pageList: [10,20,30]
			" style="width:100%;height:100%;">
		<thead>
		<tr>
			<th data-options="field:'user_id',width:80">唯一标识</th>
			<th data-options="field:'user_name',width:80">用户名</th>
			<th data-options="field:'nickname',width:80">昵称</th>
			<th data-options="field:'real_name',width:80">真实姓名</th>
			<th data-options="field:'sex',width:80">性别</th>
			<th data-options="field:'user_mobile',width:80">手机号码</th>
			<th data-options="field:'user_email',width:100">邮箱</th>
			<th data-options="field:'create_time',width:100">创建时间</th>
			<th data-options="field:'operating',width:80,formatter:getBtn">操作</th>
		</tr>
		</thead>
	</table>
	<div id="tb">
		<span>姓名:</span>
		<input  class="easyui-textbox" id="userName" name="userName" />
		<span>手机号:</span>
		<input  class="easyui-textbox" id="userMobile" name="userMobile" />
		<a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-search',plain:true" onclick="$('#users').datagrid('load', {userName: $('#userName').val(), userMobile: $('#userMobile').val()});">查询</a>
		<a href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true" onclick="parent.easyui.createWindow('用户新增', '${app}/sysmgr/user/edit.do?method=create', '650px', '330px', window.name);">新增</a>
	</div>
	</body>
    <script type="text/javascript">
		function getBtn(value, row, index) {
			return '<a href="javascript:;" class="easyui-linkbutton" onclick="deleteUser('+row.user_id+')">删除</a>&nbsp;'+
					'<a href="javascript:;" class="easyui-linkbutton" onclick="parent.easyui.createWindow(\'用户修改\', \'${app}/sysmgr/user/edit.do?method=edit&userId='+row.user_id+'\', \'650px\', \'330px\', window.name);">编辑</a>&nbsp;'+
					'<a href="javascript:;" class="easyui-linkbutton" onclick="showUserRole('+row.user_id+')">角色</a>&nbsp;';
		}
		function onLoadSuccess(data){
			$('.easyui-linkbutton').linkbutton();
		}
		function reloadUsers(){
			$('#users').datagrid('reload');
		}
		function deleteUser(userId){
			parent.easyui.confirm('系统提醒', '您确定要删除该条记录吗？', function(r){
				if (r){
					parent.layer.load(2);
					common.ajax('${app}/sysmgr/user/delete.do', 'userId='+userId,
						'POST', 'json', false,
						function(result){
							parent.layer.closeAll('loading');
							parent.easyui.msgShow('系统提醒', result.msg, 3000, 250, 100);
							if (result.result == 1) {
								reloadUsers();
							}
						}
					);
				}
			});
		}
		function showUserRole(userId){
			parent.easyui.createWindow('用户角色', '${app}/sysmgr/user/userRole.do?userId='+userId, '650px', '300px', window.name);
		}
    </script>
</html>